/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DatosEcocardiogramaPanel.java
 *
 * Created on 17/01/2011, 17:22:06
 */

package presentacion.examen;

import hibernate.objeto.HolterDePresionEstudioCardiologia;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JDialog;
import javax.swing.JSpinner.DefaultEditor;
import logica.CapaLogica;
import presentacion.CapaPresentacion;
import presentacion.utilidad.maquetado.Fuente;
import presentacion.utilidad.maquetado.InformeError;

/**
 *
 * @author Gonzalo
 */
public class DatosHolterDePresionPanel extends javax.swing.JPanel {

    /** Creates new form DatosEcocardiogramaPanel */
    public DatosHolterDePresionPanel() {
        initComponents();
        setearEventosQueCapturanTeclaEnterYEscape();
    }

    /**
     * Setea datos de la ventana.
     *
     */
    public void personalizarJDialog(HolterDePresionEstudioCardiologia
            holterDePresionEstudioCardiologia) {
        this.holterDePresionEstudioCardiologia = 
                holterDePresionEstudioCardiologia;
        exhibirDatosEnPantalla();
        if(CapaPresentacion.modoVisualizacion) {
            inhabilitarCampos();
        }
    }

    /**
     * Permite visualizar los detalles de la evolución.
     *
     */
    private void exhibirDatosEnPantalla() {
        if (holterDePresionEstudioCardiologia.
                getDuracionEnHorasHolterDePresionEstudioCardiologia().
                equalsIgnoreCase("24")) {
            veinticuatroDuracionEnHorasHolterDePresion.setSelected(true);
            cuarentayochoDuracionEnHorasHolterDePresion.setSelected(false);
        } else {
            veinticuatroDuracionEnHorasHolterDePresion.setSelected(false);
            cuarentayochoDuracionEnHorasHolterDePresion.setSelected(true);
        }
        tensionArterialDiastolicaHolterDePresion.setValue(
                holterDePresionEstudioCardiologia.
                getTensionArterialDiastolicaHolterDePresionEstudioCardiolog());
        tensionArterialMaximaHolterDePresion.setValue(
                holterDePresionEstudioCardiologia.
                getTensionArterialMaximaHolterDePresionEstudioCardiologia());
        tensionArterialMinimaHolterDePresion.setValue(
                holterDePresionEstudioCardiologia.
                getTensionArterialMinimaHolterDePresionEstudioCardiologia());
        tensionArterialPromedioHolterDePresion.setValue(
                holterDePresionEstudioCardiologia.
                getTensionArterialPromedioHolterDePresionEstudioCardiologia());
        tensionArterialSistolicaHolterDePresion.setValue(
                holterDePresionEstudioCardiologia.
                getTensionArterialSistolicaHolterDePresionEstudioCardiologi());
        conclusionesHolterDePresion.setText(
                holterDePresionEstudioCardiologia.
                getConclusionHolterDePresionEstudioCardiologia());
        conclusionesHolterDePresion.setCaretPosition(0);
    }

    /**
     * Pone en false la propiedad enabled de todos los campos de ingreso.
     *
     */
    private void inhabilitarCampos() {
        veinticuatroDuracionEnHorasHolterDePresion.setEnabled(true);
        cuarentayochoDuracionEnHorasHolterDePresion.setEnabled(true);
        tensionArterialDiastolicaHolterDePresion.setEnabled(true);
        tensionArterialMaximaHolterDePresion.setEnabled(true);
        tensionArterialMinimaHolterDePresion.setEnabled(true);
        tensionArterialPromedioHolterDePresion.setEnabled(true);
        tensionArterialSistolicaHolterDePresion.setEnabled(true);
        conclusionesHolterDePresion.setEnabled(true);
    }

    /**
     * Valida en conjunto todos los campos. Aquellos que son obligatorios y los
     * que no.
     *
     * @return true si el objeto está listo para cargarse, false en caso
     * contrario
     */
    public boolean validarCampos() {
        boolean esDuracionEnHorasValida = validarCamposDuracionEnHoras();

        return esDuracionEnHorasValida;
    }

    /**
     * Valida los campos correspondiente al campo Duracion en horas.
     *
     * @return true si los campos estan listos para cargarse, false en caso
     * contrario
     */
    private boolean validarCamposDuracionEnHoras() {
        boolean retorno;

        if (!veinticuatroDuracionEnHorasHolterDePresion.isSelected() &&
                !cuarentayochoDuracionEnHorasHolterDePresion.isSelected()) {
            textoDuracionEnHorasHolterDePresion.setForeground(
                    Fuente.COLOR_ERROR);
            textoDuracionEnHorasHolterDePresion.setToolTipText(
                    InformeError.
                    INFORME_ERROR_CARDIOLOGICO_HOLTER_DE_PRESION_DURACION_EN_HORAS);
            retorno = false;
        } else {
            textoDuracionEnHorasHolterDePresion.setForeground(Fuente.COLOR_NORMAL);
            textoDuracionEnHorasHolterDePresion.setToolTipText(null);
            retorno = true;
        }

        return retorno;
    }

    /**
     * Recopila los datos del panel para colocarlos dentro del arreglo.
     *
     * @param datosEstudioCardiologia El arreglo a cargar
     */
    public void recopilarDatos(Object[] datosEstudioCardiologia) {

        if (veinticuatroDuracionEnHorasHolterDePresion.isSelected()) {
            datosEstudioCardiologia[CapaLogica.
                    ESTUDIO_CARDIOLOGIA_HOLTER_DE_PRESION_DURACION_EN_HORAS] =
                "24";
        } else {
            datosEstudioCardiologia[CapaLogica.ESTUDIO_CARDIOLOGIA_HOLTER_DE_PRESION_DURACION_EN_HORAS] =
                "48";
        }
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_HOLTER_DE_PRESION_TENSION_ARTERIAL_DIASTOLICA] =
                tensionArterialDiastolicaHolterDePresion.getValue();
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_HOLTER_DE_PRESION_TENSION_ARTERIAL_MAXIMA] =
                tensionArterialMaximaHolterDePresion.getValue();
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_HOLTER_DE_PRESION_TENSION_ARTERIAL_MINIMA] =
                tensionArterialMinimaHolterDePresion.getValue();
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_HOLTER_DE_PRESION_TENSION_ARTERIAL_PROMEDIO] =
                tensionArterialPromedioHolterDePresion.getValue();
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_HOLTER_DE_PRESION_TENSION_ARTERIAL_SISTOLICA] =
                tensionArterialSistolicaHolterDePresion.getValue();
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_HOLTER_DE_PRESION_CONCLUSIONES] =
                conclusionesHolterDePresion.getText();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        valvulasEcocardiograma1 = new javax.swing.JTextField();
        textoDuracionEnHorasHolterDePresion = new javax.swing.JLabel();
        textoTensionArterialPromedioHolterDePresion = new javax.swing.JLabel();
        tensionArterialPromedioHolterDePresion = new javax.swing.JSpinner();
        tensionArterialDiastolicaHolterDePresion = new javax.swing.JSpinner();
        textoTensionArterialSistolicaHolterDePresion = new javax.swing.JLabel();
        tensionArterialSistolicaHolterDePresion = new javax.swing.JSpinner();
        textoTensionArterialDiastolicaHolterDePresion = new javax.swing.JLabel();
        textoTensionArterialMaximaHolterDePresion = new javax.swing.JLabel();
        textoTensionArterialMinimaHolterDePresion = new javax.swing.JLabel();
        textoConclusionesHolterDePresion = new javax.swing.JLabel();
        conclusionesScrollPane = new javax.swing.JScrollPane();
        conclusionesHolterDePresion = new javax.swing.JTextArea();
        tensionArterialMaximaHolterDePresion = new javax.swing.JSpinner();
        tensionArterialMinimaHolterDePresion = new javax.swing.JSpinner();
        veinticuatroDuracionEnHorasHolterDePresion = new javax.swing.JRadioButton();
        cuarentayochoDuracionEnHorasHolterDePresion = new javax.swing.JRadioButton();

        valvulasEcocardiograma1.setPreferredSize(new java.awt.Dimension(78, 20));

        textoDuracionEnHorasHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        textoDuracionEnHorasHolterDePresion.setText("Duración en horas");
        textoDuracionEnHorasHolterDePresion.setPreferredSize(new java.awt.Dimension(233, 20));

        textoTensionArterialPromedioHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        textoTensionArterialPromedioHolterDePresion.setText("Tensión arterial promedio");
        textoTensionArterialPromedioHolterDePresion.setPreferredSize(new java.awt.Dimension(233, 20));

        tensionArterialPromedioHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        tensionArterialPromedioHolterDePresion.setModel(new javax.swing.SpinnerNumberModel());
        tensionArterialPromedioHolterDePresion.setPreferredSize(new java.awt.Dimension(70, 20));

        tensionArterialDiastolicaHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        tensionArterialDiastolicaHolterDePresion.setModel(new javax.swing.SpinnerNumberModel());
        tensionArterialDiastolicaHolterDePresion.setPreferredSize(new java.awt.Dimension(70, 20));

        textoTensionArterialSistolicaHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        textoTensionArterialSistolicaHolterDePresion.setText("Tensión arterial sistólica");
        textoTensionArterialSistolicaHolterDePresion.setPreferredSize(new java.awt.Dimension(233, 20));

        tensionArterialSistolicaHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        tensionArterialSistolicaHolterDePresion.setModel(new javax.swing.SpinnerNumberModel());
        tensionArterialSistolicaHolterDePresion.setPreferredSize(new java.awt.Dimension(70, 20));

        textoTensionArterialDiastolicaHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        textoTensionArterialDiastolicaHolterDePresion.setText("Tensión arterial diastólica");
        textoTensionArterialDiastolicaHolterDePresion.setPreferredSize(new java.awt.Dimension(233, 20));

        textoTensionArterialMaximaHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        textoTensionArterialMaximaHolterDePresion.setText("Tensión arterial máxima");
        textoTensionArterialMaximaHolterDePresion.setPreferredSize(new java.awt.Dimension(233, 20));

        textoTensionArterialMinimaHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        textoTensionArterialMinimaHolterDePresion.setText("Tensión arterial mínima");
        textoTensionArterialMinimaHolterDePresion.setPreferredSize(new java.awt.Dimension(233, 20));

        textoConclusionesHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        textoConclusionesHolterDePresion.setText("Conclusiones");
        textoConclusionesHolterDePresion.setPreferredSize(new java.awt.Dimension(102, 20));

        conclusionesScrollPane.setPreferredSize(new java.awt.Dimension(222, 80));

        conclusionesHolterDePresion.setColumns(20);
        conclusionesHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        conclusionesHolterDePresion.setRows(4);
        conclusionesScrollPane.setViewportView(conclusionesHolterDePresion);

        tensionArterialMaximaHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        tensionArterialMaximaHolterDePresion.setModel(new javax.swing.SpinnerNumberModel());
        tensionArterialMaximaHolterDePresion.setPreferredSize(new java.awt.Dimension(70, 20));

        tensionArterialMinimaHolterDePresion.setFont(Fuente.FUENTE_TEXTFIELD);
        tensionArterialMinimaHolterDePresion.setModel(new javax.swing.SpinnerNumberModel());
        tensionArterialMinimaHolterDePresion.setPreferredSize(new java.awt.Dimension(70, 20));

        veinticuatroDuracionEnHorasHolterDePresion.setFont(Fuente.FUENTE_CHECKBOX);
        veinticuatroDuracionEnHorasHolterDePresion.setForeground(Fuente.COLOR_NORMAL);
        veinticuatroDuracionEnHorasHolterDePresion.setText("24");
        veinticuatroDuracionEnHorasHolterDePresion.setPreferredSize(new java.awt.Dimension(42, 20));
        veinticuatroDuracionEnHorasHolterDePresion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                veinticuatroDuracionEnHorasHolterDePresionActionPerformed(evt);
            }
        });

        cuarentayochoDuracionEnHorasHolterDePresion.setFont(Fuente.FUENTE_CHECKBOX);
        cuarentayochoDuracionEnHorasHolterDePresion.setForeground(Fuente.COLOR_NORMAL);
        cuarentayochoDuracionEnHorasHolterDePresion.setText("48");
        cuarentayochoDuracionEnHorasHolterDePresion.setPreferredSize(new java.awt.Dimension(42, 20));
        cuarentayochoDuracionEnHorasHolterDePresion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cuarentayochoDuracionEnHorasHolterDePresionActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(textoConclusionesHolterDePresion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoTensionArterialMinimaHolterDePresion, 0, 0, Short.MAX_VALUE)
                    .addComponent(textoTensionArterialMaximaHolterDePresion, 0, 0, Short.MAX_VALUE)
                    .addComponent(textoDuracionEnHorasHolterDePresion, javax.swing.GroupLayout.Alignment.TRAILING, 0, 0, Short.MAX_VALUE)
                    .addComponent(textoTensionArterialPromedioHolterDePresion, 0, 0, Short.MAX_VALUE)
                    .addComponent(textoTensionArterialSistolicaHolterDePresion, 0, 0, Short.MAX_VALUE)
                    .addComponent(textoTensionArterialDiastolicaHolterDePresion, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(conclusionesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(veinticuatroDuracionEnHorasHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cuarentayochoDuracionEnHorasHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(tensionArterialPromedioHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialSistolicaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialDiastolicaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialMaximaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialMinimaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(31, 31, 31))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoDuracionEnHorasHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(veinticuatroDuracionEnHorasHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cuarentayochoDuracionEnHorasHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoTensionArterialPromedioHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialPromedioHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoTensionArterialSistolicaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialSistolicaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoTensionArterialDiastolicaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialDiastolicaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoTensionArterialMaximaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialMaximaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoTensionArterialMinimaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialMinimaHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(conclusionesScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textoConclusionesHolterDePresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void veinticuatroDuracionEnHorasHolterDePresionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_veinticuatroDuracionEnHorasHolterDePresionActionPerformed
        if (veinticuatroDuracionEnHorasHolterDePresion.isSelected()) {
            cuarentayochoDuracionEnHorasHolterDePresion.setSelected(false);
        }
}//GEN-LAST:event_veinticuatroDuracionEnHorasHolterDePresionActionPerformed

    private void cuarentayochoDuracionEnHorasHolterDePresionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cuarentayochoDuracionEnHorasHolterDePresionActionPerformed
        if (cuarentayochoDuracionEnHorasHolterDePresion.isSelected()) {
            veinticuatroDuracionEnHorasHolterDePresion.setSelected(false);
        }
}//GEN-LAST:event_cuarentayochoDuracionEnHorasHolterDePresionActionPerformed

    /**
     * Setea en cada componente del JDialog los eventos que capturarán la tecla
     * enter y escape.
     */
    private void setearEventosQueCapturanTeclaEnterYEscape() {
        //Declaración del evento a capturar
        KeyListener keyListenerEscape = new KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
                    cerrarVentana();
                }
            }
        };

        //Setear eventos
        veinticuatroDuracionEnHorasHolterDePresion.addKeyListener(keyListenerEscape);
        cuarentayochoDuracionEnHorasHolterDePresion.addKeyListener(keyListenerEscape);
        ((DefaultEditor) tensionArterialDiastolicaHolterDePresion.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        ((DefaultEditor) tensionArterialMaximaHolterDePresion.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        ((DefaultEditor) tensionArterialMinimaHolterDePresion.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        ((DefaultEditor) tensionArterialPromedioHolterDePresion.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        ((DefaultEditor) tensionArterialSistolicaHolterDePresion.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        conclusionesHolterDePresion.addKeyListener(keyListenerEscape);
    }

    private void cerrarVentana() {
        JDialog jdialog = (JDialog)
                this.getParent().getParent().getParent().getParent().
                getParent().getParent().getParent().getParent().
                getParent().getParent().getParent().getParent().getParent();
        jdialog.dispose();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea conclusionesHolterDePresion;
    private javax.swing.JScrollPane conclusionesScrollPane;
    private javax.swing.JRadioButton cuarentayochoDuracionEnHorasHolterDePresion;
    private javax.swing.JSpinner tensionArterialDiastolicaHolterDePresion;
    private javax.swing.JSpinner tensionArterialMaximaHolterDePresion;
    private javax.swing.JSpinner tensionArterialMinimaHolterDePresion;
    private javax.swing.JSpinner tensionArterialPromedioHolterDePresion;
    private javax.swing.JSpinner tensionArterialSistolicaHolterDePresion;
    private javax.swing.JLabel textoConclusionesHolterDePresion;
    private javax.swing.JLabel textoDuracionEnHorasHolterDePresion;
    private javax.swing.JLabel textoTensionArterialDiastolicaHolterDePresion;
    private javax.swing.JLabel textoTensionArterialMaximaHolterDePresion;
    private javax.swing.JLabel textoTensionArterialMinimaHolterDePresion;
    private javax.swing.JLabel textoTensionArterialPromedioHolterDePresion;
    private javax.swing.JLabel textoTensionArterialSistolicaHolterDePresion;
    private javax.swing.JTextField valvulasEcocardiograma1;
    private javax.swing.JRadioButton veinticuatroDuracionEnHorasHolterDePresion;
    // End of variables declaration//GEN-END:variables
    private HolterDePresionEstudioCardiologia holterDePresionEstudioCardiologia;
}
